
  <script LANGUAGE="javascript">
function check()
{
  <%#*if(document.getElementById('checkall').innerHtml=="Select All")%>
      if(document.getElementById('checkstatus').value==1)
    {
      document.getElementById('selectall').innerHTML="Deselect All";
          var inputs = document.getElementsByTagName('input');
          var checkboxes = [];
          for (var i = 0; i < inputs.length; i++) {

              if (inputs[i].type == 'checkbox') {
              inputs[i].checked =true;

              }

          }
           document.getElementById('checkstatus').value=0;


    }
    else if(document.getElementById('checkstatus').value==0)
    {
      
      document.getElementById('selectall').innerHTML="Select All";
          var inputs = document.getElementsByTagName('input');
          var checkboxes = [];
          for (var i = 0; i < inputs.length; i++) {

              if (inputs[i].type == 'checkbox') {
              inputs[i].checked =false;

              }
          }


document.getElementById('checkstatus').value=1;    }

}
</script>
  <%require 'htmlentities'
  coder = HTMLEntities.new
  %>


	<div class="user-accounts-left-column">
    	<div class="user-accounts-image-container">
        	<div class="user-accounts-image">
	          <%=image_tag("user-accounts-image.jpg", :border=>"0px",:width=>"148") -%>
    		</div>
            <div class="user-accounts-edit-image">
            	<a href="">Add an image</a>
            </div>
        </div>
        <div class="user-accounts-fields">
        	<div class="user-accounts-username">
            	<%= User.find(session[:user]).full_name -%>
            </div>
            <div class="user-accounts-type">
              <%unless User.find(session[:user]).user_type_id.nil?%>
            	<%= UserType.find(User.find(session[:user]).user_type_id).name -%>
                <%end -%>
            </div>
            <div class="user-accounts-university">
            	Delhi University
            </div>
        </div>
        <div class="user-accounts-buttons">
        	<div class="user-accounts-post-button">
            	<%=image_tag("user-accounts-post-button.jpg", :border=>"0px",:width=>"150") -%>
            </div>
        	<div class="user-accounts-invite-button">
                <%=image_tag("user-accounts-invite-button.jpg", :border=>"0px",:width=>"150") -%>
            </div>
        	<div class="user-accounts-find-button">
                <%=image_tag("user-accounts-find-button.jpg", :border=>"0px",:width=>"150") -%>
            </div>
        	<div class="user-accounts-settings-button">
               <%=image_tag("user-accounts-settings-button.jpg", :border=>"0px",:width=>"150") -%>
            </div>
        </div>
        <div class="user-accounts-bar">
        	<div class="user-accounts-bar-image">
             <%=image_tag("user-accounts-bar.jpg", :border=>"0px",:width=>"150") -%>
            </div>
            <div class="user-accounts-bar-reading">
            	Your profile is 25%.<br/>
                Complete it. <a>Edit</a>
            </div>
        </div>
    </div>
    <div class="user-accounts-right-column">
    	<div class="user-accounts-welcome">
        	Welcome <%= User.find(session[:user].id).full_name -%>,
        </div>
        <div class="user-accounts-tab">
            <ul>
                <li class="selected"><a href="">Dashboard</a></li>
                <li><%= link_to  "My Ads" ,:controller=>"login",:action => "recently_posted_ads" -%></li>
                <li><%=link_to_remote "My Info", :url=>{:action => "my_info", :id =>session[:user].id,:controller=>"login"},:update=>"user-accounts-dashboard" %></li>
                <li><%= link_to_remote  "Saved Ads" ,:url => {:controller=>"login",:action => "saved_ads"}, :update => "user-accounts-dashboard" -%></li>
                <li><a href="">Notification</a></li>
            </ul>
        </div>
        <div class="user-accounts-profile-view">
          <%=image_tag("others-profile-view.jpg", :border=>"0px",:width=>"20",:height=>"20") -%>
             <a href="">View my profile as others see it</a>
        </div>
        <div class="user-accounts-dashboard" id="user-accounts-dashboard">
        	<div class="dashboard-message"><%=image_tag("dashboard-alert.jpg", :border=>"0px",:width=>"30",:height=>"30") -%>
            
                <div class="dashboard-message-text">
	                Confirm Your Email Address: Check your email for a confirmation message from us, or <a href="">request another one</a>
    			</div>
            </div>
            <div class="dashboard-left">
            	<div class="dashboard-my-info">
                	<div class="dashboard-my-info-header">
                    	<%=image_tag("my-info.png", :border=>"0px") -%>
                        <div class="dashboard-my-info-header-text">
                        	My Info&nbsp;&nbsp;<a href="">Edit Profile</a>
                        </div>
                    </div>
                    <div class="dashboard-my-info-container">
                		<div class="dashboard-intial-info">
                          <%if User.find(session[:user]).email!='' && !User.find(session[:user]).email.nil?%>
                        	<div class="dashboard-email">
                            	<div class="dashboard-email-field">
                                	Email
                                </div>
                                <div class="dashboard-email-value">
                                	<%= User.find(session[:user]).email %>
                                </div>
                            </div>
                            <%end%>
                            <%if User.find(session[:user]).mobile_no!=0 && !User.find(session[:user]).mobile_no.nil?%>
                        	<div class="dashboard-email">
                            	<div class="dashboard-email-field">
                                	Mobile No.
                                </div>
                                <div class="dashboard-email-value">
                                	<%= User.find(session[:user]).mobile_no %>
                                </div>
                            </div>
                            <%end -%>
                            <%if User.find(session[:user]).postal_id!=0 && !User.find(session[:user]).postal_id.nil?%>
                        	<div class="dashboard-email">
                            	<div class="dashboard-email-field">
                                	Location
                                </div>
                                <div class="dashboard-email-value">
                                	 <%= User.find(session[:user]).postal_id %>
                                </div>
                            </div>
                            <%end -%>
                        </div>
                        <div class="profile-completion">
                        	<div class="profile-completion-header">
                            	Profile Completion Tips
                            </div>
                            <div class="profile-completion-fields">
                            	<ul>
                                	<li><a href="">Verify Contact Information (10%)</a></li>
                                    <li><a href="">Personal Information (15%)</a></li>
                                    <li><a href="">Current University (15%)</a></li>
                                    <li><a href="">Your Interests (15%)</a></li>
                                    <li><a href="">Educational Background (20%)</a></li>
                                    <li><a href="">Work Experience (10%)</a></li>
                                    <li><a href="">Additional Skills (5%)</a></li>
                                    <li><a href="">Post an Ad (10%)</a></li>
                                </ul>
                            </div>
                        </div>
                        <div class="my-info-tips">
                        	Tips: Add your <a href="">education background</a> to help other professional learn more about you.
                        </div>
                    </div>
                </div>
                <div class="dashboard-responses">
                	<div class="dashboard-my-info-header">
                        <%=image_tag("responses.png", :border=>"0px",:height=>"20") -%>
                        <div class="dashboard-my-info-header-text">
                        	Recent Responses&nbsp;&nbsp;<%= link_to_remote  "See All" ,:url => {:controller=>"login",:action => "recent_responses"}, :update => "user-accounts-dashboard" -%>

                        </div>
                    </div>
                    <div class="dashboard-responses-container">
                        <% @advertisment_responses.each do |ad_response| -%>
                        <% @response = Query.find_by_advertisment_id(ad_response.id, :limit=>1,:order=>"created_at desc")%>
                        <%unless @response.nil?  -%>
                                <%@response_content=@response.content -%>
                                <% @count=Query.count(:conditions=>"advertisment_id="+ad_response.id.to_s,:order=>"created_at desc")-%>
                       
                        
                		<div class="dashboard-recent-resposes">
                        	<div class="dashboard-response-ad">
                              
                            	 <%= ad_response.title %>
                                 
                            </div>
                            <div class="dashboard-response-no">
                            	<a href=""><%=@count%> <% if @count == 1%>response<%else%>responses<%end-%></a>
                            </div>
                            <div class="dashboard-responses-value">
                            	 <%=h coder.decode(excerpt(@response_content  , ' ', 30))unless @response_content.nil? -%><a href="">more</a>
                            </div>
                        </div>
                       
                        <div class="parting-line">
                        	<hr/>
                        </div>
                          <%end -%>
                      <%end -%>
                    </div>
                </div>
                <div class="dashboard-posted-ads">
                	<div class="dashboard-my-info-header">
                      <%=image_tag("posted-ads.png", :border=>"0px",:height=>"20") -%>
                    	<div class="dashboard-my-info-header-text">
                        	Recently Posted Ads&nbsp;&nbsp;<%= link_to_remote  "See All" ,:url => {:controller=>"login",:action => "recently_posted_ads"}, :update => "user-accounts-dashboard" -%>
                        </div>
                    </div>
                    <div class="dashboard-posted-ads-container">
                      <%@user_advertisments.each do |advertisment| -%>
                		<div class="dashboard-recent-resposes">
                        	<div class="dashboard-response-ad">
                            	<%=link_to h(coder.decode(advertisment.title.capitalize)), { :controller=> "advertisments" , :action=>"show" ,:id => advertisment} -%>
                            </div>
                            <div class="dashboard-response-no">
                               	<%=link_to "Edit", :action => "edit_ad", :id => advertisment.id%>&nbsp;|&nbsp;<a href="">Delete</a>
                            </div>
                            <div class="dashboard-posted-on">
                            	<%=advertisment.created_at.to_formatted_s(:long_ordinal) -%>
                            </div>
                        </div>
                        <div class="parting-line">
                        	<hr/>
                        </div>
                        
                     <%end -%>
                    </div>
                </div>
                <div class="dashboard-saved-ads">
                	<div class="dashboard-my-info-header">
                      <%=image_tag("saved.png", :border=>"0px",:height=>"20") -%>
                    	<div class="dashboard-my-info-header-text">
                        	Saved Ads&nbsp;&nbsp;<%= link_to_remote  "See All" ,:url => {:controller=>"login",:action => "saved_ads"}, :update => "user-accounts-dashboard" -%>
                        </div>
                    </div>
                    <div class="dashboard-saved-ads-container">
                        <% @saved_advertisments.each do |saved_ads| -%>
                        <% @advertisment_id  = saved_ads.advertisment_id  -%>
                        <% @ad = Advertisment.find_by_id(@advertisment_id)%>
                        <%@subcategory_id=@ad.sub_category_id -%>
                        <%@subcategory_name=SubCategory.find(@subcategory_id).name -%>
                        <%@category_id=SubCategory.find(@subcategory_id).category_id-%>
                        <%@category_name=Category.find(@category_id).name -%>

         <br>

                	<div class="dashboard-recent-resposes">
                        	<div class="dashboard-response-ad">
                              <%=link_to h(coder.decode(@ad.title.capitalize)), { :controller=> "advertisments" , :action=>"show" ,:id => @ad} -%>
                            </div>
                            <div class="dashboard-response-no">
                            	<a href="">Delete</a>
                            </div>
                            <div class="dashboard-posted-on">
                            	<%=@category_name-%> / <%=@subcategory_name-%>
                            </div>
                            <div class="dashboard-saved-in">
                            	Saved in: <%=saved_ads.folder -%>
                            </div>
                        </div>
                        <div class="parting-line">
                        	<hr/>
                        </div>
                       
                      <%end -%>
                    </div>
                </div>
            </div>
          <div class="dashboard-right">
            	<div class="dashboard-classifieds">
                	<div class="dashboard-classifieds-header">
                      <%=image_tag("relevant-ads.png", :border=>"0px",:height=>"20") -%>
                    	<div class="dashboard-classifieds-header-text">
                        	Relevant Ads&nbsp;&nbsp;<a href="">See all</a>
                        </div>
                    </div>
 <div class="dashboard-classifieds-ads-container">
                      <%@user_advertisments_relevant.each do |advertisment| -%>
                        <%@subcategory_id=advertisment.sub_category_id -%>
                        <%@category_id=SubCategory.find(@subcategory_id).category_id-%>
                        <%@group_id=Category.find(@category_id).group_id-%>
                        <%@opposite_category_ids=Category.find(:all,:conditions=>"id!="+@category_id.to_s+ " and group_id="+@group_id.to_s)-%>
                        <%@opposite_category_ids.each do |category| -%>
                            <%@opposite_subcategory_ids=SubCategory.find(:all,:conditions=>"category_id="+category.id.to_s)-%>
                            <%counter=0%>
                            
                              <%@opposite_subcategory_ids.each do |subcategory| -%>
                                <% @relevant_ads=Advertisment.find(:all, :conditions=>"sub_category_id = "+subcategory.id.to_s,:order =>"created_at DESC")%>
                                    <%  @relevant_ads.each do |relevant_ad|%>
                                       <%if counter < 2 %>
                    	<div class="dashboard-classifieds-ad">
                            <div class="dashboard-classifieds-ads-heading">
                                <%=link_to h(coder.decode(relevant_ad.title.capitalize)), { :controller=> "advertisments" , :action=>"show" ,:id => relevant_ad} -%>
                            </div>
                            <div class="dashboard-classifieds-ads-category">
                                <%= h category.name -%> / <%= subcategory.name -%>
                            </div>
                            <div class="dashboard-classifieds-ads-details">
                                Posted by :
                                  <%= User.find(relevant_ad.user_id.to_i).full_name%>
                            </div>
                        </div>
                         <%counter=counter+1%>
                    
                     <%end -%>
                    <%end -%>
              <%end -%>
            <%end -%>

      <%end -%>
</div>
                  </div>
                   <div class="parting-line-2">
                        	<hr/>
                        </div>

                <div class="dashboard-classifieds">
                	<div class="dashboard-classifieds-header">
                        <%=image_tag("college-ads.png", :border=>"0px",:height=>"20") -%>
                         <div class="dashboard-classifieds-header-text">
	                        <%=@university_name-%> Ads&nbsp;&nbsp;<a href="">See all</a>
    					</div>
                    </div>
                    <div class="dashboard-classifieds-ads-container">
                       <%@campus_advertisments.each do |advertisment| -%>
                         <%@subcategory_id=advertisment.sub_category_id -%>
                         <%@subcategory_name=SubCategory.find(@subcategory_id).name -%>
                         <%@category_id=SubCategory.find(@subcategory_id).category_id-%>
                         <%@category_name=Category.find(@category_id).name -%>
                    	<div class="dashboard-classifieds-ad">
                            <div class="dashboard-classifieds-ads-heading">
                              <%=link_to h(coder.decode(advertisment.title.capitalize)), { :controller=> "advertisments" , :action=>"show" ,:id => advertisment} -%>
                            </div>
                            <div class="dashboard-classifieds-ads-category">
                                <%= @category_name -%> / <%= @subcategory_name -%>
                            </div>
                            <div class="dashboard-classifieds-ads-details">
                                Posted by : 
  <%=User.find(advertisment.user_id).full_name%>
                            </div>
                        </div>
                       <%end -%>
                   </div>
                    </div>
                   <div class="parting-line-2">
                        	<hr/>
                        </div>

              <!-- <div class="dashboard-classifieds">
                	<div class="dashboard-classifieds-header">
                         <%=image_tag("subscription-ads.png", :border=>"0px",:height=>"20") -%>
                    	<div class="dashboard-classifieds-header-text">
                        	Personal Subscription&nbsp;&nbsp;<a href="">See all</a>
                        </div>
                    </div>
                    <div class="dashboard-classifieds-ads-container">
                    	<div class="dashboard-classifieds-ad">
                            <div class="dashboard-classifieds-ads-heading">
                                <a href="">Chief Architect / Principle Architect for Java</a>
                            </div>
                            <div class="dashboard-classifieds-ads-category">
                                Job / Full time
                            </div>
                            <div class="dashboard-classifieds-ads-details">
                                Posted by : Amar Singh
                            </div>
                        </div>
                        <div class="dashboard-classifieds-ad">
                            <div class="dashboard-classifieds-ads-heading">
                                <a href="">Chief Architect / Principle Architect for Java</a>
                            </div>
                            <div class="dashboard-classifieds-ads-category">
                                Job / Full time
                            </div>
                            <div class="dashboard-classifieds-ads-details">
                                Posted by : Amar Singh
                            </div>
                         </div>
                         <div class="dashboard-classifieds-ad">
                            <div class="dashboard-classifieds-ads-heading">
                                <a href="">Chief Architect / Principle Architect for Java</a>
                            </div>
                            <div class="dashboard-classifieds-ads-category">
                                Job / Full time
                            </div>
                            <div class="dashboard-classifieds-ads-details">
                                Posted by : Amar Singh
                            </div>
                        </div>
                        <div class="dashboard-classifieds-ad">
                            <div class="dashboard-classifieds-ads-heading">
                                <a href="">Chief Architect / Principle Architect for Java</a>
                            </div>
                            <div class="dashboard-classifieds-ads-category">
                                Job / Full time
                            </div>
                            <div class="dashboard-classifieds-ads-details">
                                Posted by : Amar Singh
                            </div>
                        </div>
                        <div class="dashboard-classifieds-ad">
                            <div class="dashboard-classifieds-ads-heading">
                                <a href="">Chief Architect / Principle Architect for Java</a>
                            </div>
                            <div class="dashboard-classifieds-ads-category">
                                Job / Full time
                            </div>
                            <div class="dashboard-classifieds-ads-details">
                                Posted by : Amar Singh
                            </div>
                        </div>
                   </div>
                </div>-->
            </div>
        </div>
    </div>




